// 金额带两位小数
export const floatPrices = (price) => {
  let f = parseFloat(price)
  if (isNaN(f)) return false
  f = Math.round(price * 100) / 100
  let _result = f.toString()
  let rs = _result.indexOf('.')
  if (rs < 0) {
    rs = _result.length
    _result += '.'
  }
  while (_result.length <= rs + 2) {
    _result += '0'
  }
  return _result
}
// 手机号码中间4位虚化
export const phoneReplace = (phone = '') => {
  let hiddenNumber = phone.substring(3, 7)
  phone = phone.replace(hiddenNumber, '****')
  return phone
}

// 余额,承兑的价格显示
export const amountFilter = (amount) => {
  if (!amount) return
  let result = ''
  let tagReg = /\+-/i
  let useReg = /-/i
  tagReg.test(amount) || useReg.test(amount) ? result = `-￥${amount.substr(2)}` : result = `+￥${amount.substr(1)}`
  return result
}
